using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Padelcenter.Operational
{
    public class Config
    {
        public Config()
        { 
            
        }

        public string GetAppSetting(string key)
        {
            if (key == null) throw new ArgumentNullException("key");
            if (key.Length > 0)
            {
                if (ConfigurationManager.AppSettings[key].ToString() != null)
                {
                    try
                    {
                        return ConfigurationManager.AppSettings[key].ToString();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                }
                else
                {
                    return string.Empty;
                }
            }
            return string.Empty;
        }

        public string ConnString(string key)
        {
            if (key == null) throw new ArgumentNullException("key");
            if (key.Length > 0)
            {
                if (ConfigurationManager.ConnectionStrings[key].ToString() != null)
                {
                    try
                    {
                        return ConfigurationManager.ConnectionStrings[key].ToString();    
                    }
                    catch(Exception ex)
                    {
                        throw ex;
                    }
                    
                }
                else
                {
                    return string.Empty;
                }
            }
            return string.Empty;
        }
    }
}
